import request from "@/utils/service";

// 单点登录验证接口
export function sso(params) {
    return request({
        url: "/simop/sso",
        method: "get",
        params,
    });
}

// 根据问题顺序获取课程问题（对话框）
export function queryTaskByMore(data) {
    return request({
        url: "/proCourseTask/queryByMore",
        method: "post",
        data,
    });
}

// 获取音频文件
export function selectAudio(data) {
    return request({
        url: "/simop/selectAudio",
        method: "post",
        data,
    });
}

// 获取实操课程
export function selectCourseFlow(data) {
    return request({
        url: "/simop/selectCourseFlow",
        method: "post",
        data,
    });
}

// 获取实操课程下一节点底图与元素信息
export function selectNextPicture(data) {
    return request({
        url: "/simop/selectNextPicture",
        method: "post",
        data,
    });
}

// 提交实操数据
export function uploadCourseTrack(data) {
    return request({
        url: "/simop/uploadCourseTrack",
        method: "post",
        data,
    });
}

// 重新答题
export function deleteFlow(data) {
    return request({
        url: "/simop/deleteFlow",
        method: "post",
        data,
    });
}

// 答题结果统计
export function consequence(data) {
    return request({
        url: "/simop/consequence",
        method: "post",
        data,
    });
}

// 结束答题
export function over(data) {
    return request({
        url: "/simop/over",
        method: "post",
        data,
    });
}

/**
 * 获取提示信息
 * @param data {{
 *     questionId:string, pageId:string
 * }}
 * @return {*}
 */
export function selectCourseHint(data) {
    return request({
        url: "/simop/selectCourseHint",
        method: "post",
        data,
    });
}

/**
 * 获取提示信息
 * @param data {{
 *     questionId:string, pageId:string
 * }}
 * @return {*}
 */
export function selectCourseHintForPreview(data) {
    return request({
        url: "/questionConfig/selectCourseHint",
        method: "post",
        data,
    });
}

export function selectNextCourseHint(questionId, pageId, elementOrder) {
    return request({
        url: "/questionConfig/selectNextCourseHint",
        method: "post",
        data: {
            questionId,
            pageId,
            elementOrder
        },
    });

}

/**
 * 查询课程底图列表
 * @param currentUserUnique 单点登录返回
 * @return {*}
 */
export function queryCourseImgList(currentUserUnique) {
    return request({
        microService: "beans",
        url: "/course/courseDisplay",
        method: "post",
        data: {
            currentUserUnique
        }
    })
}

/**
 * 图库选择导入列表
 * @param currentUserUnique 单点登录返回
 * @return {*}
 */
export function queryGallery(currentUserUnique) {
    return request({
        url: "/questionConfig/selectCoursePicture",
        method: "post",
        data: {
            currentUserUnique
        }
    })
}

/**
 * 图库选择确认
 * @param questionId {string} 问题id
 * @param page {{questionId: *}[]} 页面集合
 */
export function updateCoursePicture(questionId, page) {
    return request({
        url: "/questionConfig/updateCoursePicture",
        method: "post",
        data: {
            questionId,
            page,
        }
    })
}

/**
 * 课程底图替换
 * @param questionId {string} 问题id
 * @param pageId {string} 被替换页面id
 * @param replacePageId {string} 替换页面id
 * @return {*}
 */
export function courseReplace(questionId, pageId, replacePageId) {
    return request({
        url: "/course/courseReplace",
        method: "post",
        data: {
            questionId,
            pageId,
            replacePageId
        }
    })

}

/**
 * 课程底图删除
 * @param questionId {string} 问题id
 * @param pageId {string} 页面id
 * @return {*}
 */
export function courseImgDelete(questionId, pageId) {
    return request({
        url: "/course/courseDelete",
        method: "post",
        data: {
            questionId,
            pageId
        }
    })

}

/**
 * 查询问题页面配置
 * @param questionId {string} 问题id
 * @param pageId {string} 页面id
 * @return {*}
 */
export function selectPageConfig(questionId, pageId) {
    return request({
        microService: "beans",
        url: "/questionConfig/selectPageConfig",
        method: "post",
        data: {
            questionId,
            pageId
        }
    })

}

/**
 * 保存底图是开始节点或者结果节点
 * @param questionId
 * @param pageId 底图的id
 * @param node {'1' | '2'} 1:开始节点 2:结果节点
 * @return {*}
 */
export function updateCourseNode(questionId, pageId, node) {
    return request({
        url: "/course/node",
        method: "post",
        data: {
            questionId,
            pageId,
            node
        }
    })

}

/**
 * 保存页面配置
 * @param data
 * @return {*}
 */
export function savePageConfig(data) {
    return request({
        url: "/questionConfig/savePageConfig",
        method: "post",
        data
    })

}

/**
 * 保存问题配置
 * @param data
 * @return {*}
 */
export function updatePageOrder(data) {
    return request({
        url: "/course/updatePageOrder",
        method: "post",
        data
    })

}

/**
 * 课程配置预览
 * @param questionId 问题id
 * @return {*}
 */
export function configPreview(questionId) {
    return request({
        url: "/questionConfig/configPreview",
        method: "post",
        data: {
            questionId,
        }
    })

}

/**
 * 获取一下元素数据
 * @param questionId 问题id
 * @param sendPageId 链接ID
 * @return {*}
 */
export function queryNextPicture(questionId, sendPageId) {
    return request({
        url: "/questionConfig/queryNextPicture",
        method: "post",
        data: {
            questionId,
            sendPageId
        }
    })

}

export function ssoLogin(data) {
    return request({
        url: "/sso/operationQuestionConfigSso",
        method: "post",
        data
    })
}
